#!/bin/bash -il
# 先删除之前的容器
echo "remobe old container"
docker ps -a | grep dockertest | awk '{print $1}'| xargs docker rm -f
# 删除之前的镜像
echo "romove old image"
docker rmi docker-test
# 构建镜像
mvn docker:build
# 打印当前镜像
echo "current docker images"
docker images | grep docker-test
# 启动容器
echo "start container"
docker run --name dockertest -p 8081:8081 -d docker-test
# 打印当前容器
echo "current container"
docker ps -a | grep dockertest
echo "star service success!"